#ifndef __MUTEX_H
#define __MUTEX_H

#include "SDL/SDL.h"

/**
 * Mutex, d'après une idée originale de Patrice "ZeKiller" Roy
 */
class mutex
{
	SDL_mutex *mon_mutex_;
	friend class condition;
public:
	mutex() : mon_mutex_(SDL_CreateMutex()) {}
	bool obtenir() const throw() { return SDL_mutexP(mon_mutex_) == 0; }
	bool relacher() const throw() { return SDL_mutexV(mon_mutex_) == 0; }
	~mutex() throw() { SDL_DestroyMutex(mon_mutex_); }
};

#endif
